.TH "building" 3 "Sun Sep 2 2018" "Version 2.0" "liblightmodbus" \" -*- nroff -*-
.ad l
.nh
.SH NAME
buildingBuilding liblightmodbus 
 \- 
.PP
\fBNote:\fP
.RS 4
In order to build the library CMake 3\&.3 or newer is required\&. Versions up to 1\&.3 used script-based build system, no longer maintained as of version 1\&.4\&. For more information see \fBUsing old, proprietary build system\fP\&.
.RE
.PP
The library's build configuration process is pretty complex, as the library consists of many modules that can be included in the build or omitted\&. If you want to go with default configuration first, take a look at the section below\&.
.PP
.SS "Default build configuration"
.PP
.IP "1." 4
\fCmkdir build\fP - Create a new directory for build environment
.IP "2." 4
\fCcmake \&.\&.\fP - Run CMake with no additional flags
.IP "3." 4
\fCmake all\fP - Build the library
.PP
.PP
.SS "Custom build"
.PP
The only difference between default and customized builds are the arguments passed to CMake\&.
.PP
The \fCMODULES\fP CMake variable determines what library modules and functionalities are going to be included during the build process\&. It should take value of desired module names list, separated with semicolons (and no spaces!)\&. See below for list of available modules along with short descriptions:
.IP "\(bu" 2
\fCSLAVE_BASE\fP - slave basic feature set (required by all other slave-related modules)
.IP "\(bu" 2
\fCF01S\fP - slave support for Modbus function 01
.IP "\(bu" 2
\fCF02S\fP - slave support for Modbus function 02
.IP "\(bu" 2
\fCF03S\fP - slave support for Modbus function 03
.IP "\(bu" 2
\fCF04S\fP - slave support for Modbus function 04
.IP "\(bu" 2
\fCF05S\fP - slave support for Modbus function 05
.IP "\(bu" 2
\fCF06S\fP - slave support for Modbus function 06
.IP "\(bu" 2
\fCF15S\fP - slave support for Modbus function 15
.IP "\(bu" 2
\fCF16S\fP - slave support for Modbus function 16
.IP "\(bu" 2
\fCF22S\fP - slave support for Modbus function 22
.IP "\(bu" 2
\fCMASTER_BASE\fP - master basic feature set (required by all other master-related modules)
.IP "\(bu" 2
\fCF01M\fP - master support for Modbus function 01
.IP "\(bu" 2
\fCF02M\fP - master support for Modbus function 02
.IP "\(bu" 2
\fCF03M\fP - master support for Modbus function 03
.IP "\(bu" 2
\fCF04M\fP - master support for Modbus function 04• F05M - master support for Modbus function 05
.IP "\(bu" 2
\fCF06M\fP - master support for Modbus function 06
.IP "\(bu" 2
\fCF15M\fP - master support for Modbus function 15
.IP "\(bu" 2
\fCF16M\fP - master support for Modbus function 16
.IP "\(bu" 2
\fCF22M\fP - master support for Modbus function 22
.IP "\(bu" 2
\fCSLAVE_USER_FUNCTIONS\fP - support for user-defined Modbus functions on slave side (see \fBUser-defined Modbus functions\fP)
.IP "\(bu" 2
\fCMASTER_USER_FUNCTIONS\fP - support for user-defined Modbus functions on master side (see \fBUser-defined Modbus functions\fP)
.IP "\(bu" 2
\fCREGISTER_CALLBACK\fP - slave register callback function (see \fBUser-defined Modbus register callback function\fP)
.IP "\(bu" 2
\fCCOIL_CALLBACK\fP - slave coil callback function (see \fBUser-defined Modbus register callback function\fP)
.IP "\(bu" 2
\fCNO_MASTER_DATA_BUFFER\fP - disable exclusive master’s processed data buffer (see \fBAdvanced configuration\fP)
.IP "\(bu" 2
\fCMASTER_INVASIVE_PARSING\fP - allow master to modify received frame (use with \fCNO_MASTER_DATA_BUFFER\fP)
.IP "\(bu" 2
\fCEXPERIMENTAL\fP - enable experimental features
.PP
.PP
\fBNote:\fP
.RS 4
If you don't specify any modules during configuration, these default modules are going to be included: \fCSLAVE_BASE;F01S;F02S;F03S;F04S;F05S;F06S;F15S;F16S;F22S;SLAVE_USER_FUNCTIONS;MASTER_BASE;F01M;F02M;F03M;F04M;F05M; F06M;F15M;F16M;F22M;MASTER_USER_FUNCTIONS;ADDON_EXAMINE\fP\&.
.RE
.PP
.SS "Disabling dynamic memory allocation"
.PP
Liblightmodbus can work without dynamic memory allocation\&. See \fBDisabling dynamic memory allocation\fP for more information\&.
.PP
.SS "Setting endianness"
.PP
Modbus is strictly big-endian protocol\&. That means you have to specify target system endianness when building\&. By default, CMake will check your system endianness and apply that setting, but in order to override it, set \fCENDIANNESS\fP CMake variable to either 'big' or 'little'\&.
.PP
.SS "Building for AVR"
.PP
Building the library for AVR microcontrollers is pretty easy thanks to the \fCAVR\fP CMake variable\&. If you want to build for AVR, just add \fC-DAVR=<part>\fP argument to the CMake invocation, where \fC<part>\fP is the target microcontroller type (for instance \fCatmega328\fP)\&.
.PP
.SS "Debug and release builds"
.PP
In order to specify build type - debug or release, set \fCCMAKE_BUILD_TYPE\fP to either \fCDebug\fP or \fCRelease\fP\&.
.PP
.SS "Changing compiler and linker"
.PP
To change used compiler and linker, adjust these CMake variables: \fCCMAKE_C_COMPILER\fP, \fCCMAKE_LINKER\fP\&.
.PP
.SS "Coverage testing"
.PP
Even though it's probably not what you want to do, you can enable coverage test build by setting \fCCOVERAGE_TEST\fP variable to 1\&.
.PP
.SS "Library configuration file"
.PP
During the build process, a special library configuration header file - \fC\fBinclude/lightmodbus/libconf\&.h\fP\fP is created\&. It contains macros describing current library configuration\&. Names of these macros correspond to CMake configuration variable names\&.
.PP
If you know, what you are doing you can edit this file manually, however keep in mind that the library will need rebuilding after making any changes\&. 
